package com.micro.school.system.service.impl;

import com.micro.school.common.core.context.SecurityContextHolder;
import com.micro.school.system.domain.SchoolPayWay;
import com.micro.school.system.mapper.SchoolPayWayMapper;
import com.micro.school.system.service.SchoolPayWayService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import jakarta.annotation.Resource;

import java.util.List;

/**
 * (SchoolPayWay)表服务实现类
 *
 * @author makejava
 * @since 2025-08-08 19:07:23
 */
@Service("schoolPayWayService")
public class SchoolPayWayServiceImpl implements SchoolPayWayService {
    @Resource
    private SchoolPayWayMapper schoolPayWayMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SchoolPayWay queryById(Integer id) {
        return this.schoolPayWayMapper.queryById(id, SecurityContextHolder.getUserTenantId());
    }

    /**
     * 分页查询
     *
     * @param schoolPayWay 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public List<SchoolPayWay> queryByPage(SchoolPayWay schoolPayWay) {
        schoolPayWay.setTenantId(Integer.valueOf(SecurityContextHolder.getUserTenantId()));
        return this.schoolPayWayMapper.queryAllByLimit(schoolPayWay);
    }

    /**
     * 新增数据
     *
     * @param schoolPayWay 实例对象
     * @return 实例对象
     */
    @Override
    public SchoolPayWay insert(SchoolPayWay schoolPayWay) {
        schoolPayWay.setTenantId(Integer.valueOf(SecurityContextHolder.getUserTenantId()));
        this.schoolPayWayMapper.insert(schoolPayWay);
        return schoolPayWay;
    }

    /**
     * 修改数据
     *
     * @param schoolPayWay 实例对象
     * @return 实例对象
     */
    @Override
    public boolean update(SchoolPayWay schoolPayWay) {
        schoolPayWay.setTenantId(Integer.valueOf(SecurityContextHolder.getUserTenantId()));
        return this.schoolPayWayMapper.update(schoolPayWay) > 0;
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.schoolPayWayMapper.deleteById(id,SecurityContextHolder.getUserTenantId()) > 0;
    }
}
